﻿using System;
using System.IO;
using System.Text;


namespace HAVNet.Core.IO
{
    public class TreePath
    {
        public static string getPath (string raiz, string sep, DateTime tiempo, PathDepth depth)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(raiz);
            if (! raiz.EndsWith(sep))
                sb.Append(sep);

            sb.Append(string.Format("{0:0000}", tiempo.Year));
            sb.Append(sep);

            if (depth == PathDepth.Year)
                return sb.ToString();

            sb.Append(string.Format("{0:00}", tiempo.Month));
            sb.Append(sep);

            if (depth == PathDepth.Month)
                return sb.ToString();

            sb.Append(string.Format("{0:00}", tiempo.Day));
            sb.Append(sep);

            if (depth == PathDepth.Day)
                return sb.ToString();

            sb.Append(string.Format("{0:00}", tiempo.Hour));
            sb.Append(sep);

            if (depth == PathDepth.Hour)
                return sb.ToString();

            sb.Append(string.Format("{0:00}", tiempo.Minute));
            sb.Append(sep);

            if (depth == PathDepth.Minute)
                return sb.ToString();

            sb.Append(string.Format("{0:00}", tiempo.Second));
            sb.Append(sep);

            if (depth == PathDepth.Second)
                return sb.ToString();

            sb.Append(string.Format("{0:000}", tiempo.Millisecond));
            sb.Append(sep);

            return sb.ToString();
        }
    }

    public enum PathDepth
    {
        Year,
        Month,
        Day,
        Hour,
        Minute,
        Second,
        Millisecond,
    }
}
